#include <iostream>
#include "mem_pool.h"

using namespace std;
using namespace andrew::tools::mem;

int main(int argc,char** argv)
{
	mem_pool mpool;
	if(argc != 5)
	{
		cout<<"./mem_pool mem_max_pool chunk_size test_case alloc_size"<<endl;
		return 0;
	}
	int paras[]= {atoi(argv[1]),atoi(argv[2]),atoi(argv[3]),atoi(argv[4])};
	mpool.init(paras[0],paras[1]);
	for(int i = 0;i< paras[2];i++)
	{
		char* ptr = mpool.alloc(paras[3]);
		if(ptr == NULL)
		{
			cout<<"alloc failed !"<<i<<endl;
			continue;
		}
		memset(ptr,0,paras[3]);
		sprintf(ptr,"hello_word=-----%d---",i);
		cout<<ptr<<endl;
		/*
		if(1 == mpool.release(ptr))
		{
			cout<<"free failed !"<<endl;
		}
		*/
	}


	return 0;
}
